<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
     <!--action是数据提交的网址,method是动作,其中有get和post,get提交的数据会显示,不安全,post不显示,相对安全--> 
		<form action="xxx"    onsubmit="return checkform()">
			<!--  autofocus自动获得焦点  -->
            用户: 
                <input id="username"  value="" placeholder="请输入用户名" autofocus>
                <br /><br />
            
            密码: 
                <input id="password" type="password" placeholder="请输入密码">
                <br /><br />
            
			性别: 
                <input type="radio" name="sex" checked/>男
                <input type="radio" name="sex" />女
                <br /><br />
		
			学历:
                <select id="edu">
                    <option value="专科">专科</option>
                    <option value="本科">本科</option>
                    <option value="研究生">研究生</option>
                </select>
                <br /> <br />
            
            自我介绍:
                <textarea cols="10" rows="5" id="usertext"></textarea> 
                <br /> <br />
            
            <!-- 按键： -->
            <input type="submit" value="提交">
            <input type="reset" value="清空">
		
		</form>
</body>

<script>
     
        function checkform() {
            var name = document.getElementById("username").value;
            var pass = document.getElementById("password").value
            if(name == ""){
                alert("帐号不能为空！");
                return false; // 阻止表单的提交
            }else if(name != "admin"){
                alert("用户名错误，请重新输入！")
                return false;
                }
            else if(pass.length !=6){
                alert("密码错误！")
                return false;
            }
            else if(name === "admin"){
                var str = document.getElementById("usertext").value
                alert(str)
                return true; // 放行，让表单提交
            }
        } 
     
    </script>
</html>
